package PangController;

import java.awt.event.KeyEvent;

/**
 * Created by baraaorabi on 5/1/15.
 */
public class InputManager {

    private final MapEngine mapEngine;
    public static final int LEFT  = 0;
    public static final int RIGHT = 1;
    public static final int SHOOT = 2;
    public static final int PAUSE = 3;
    private final GameEngine gameEngine;
    private boolean[] keysPressed = new boolean[4];
    //private PangKeyListener pangKeyListener;

    public InputManager(MapEngine mapEngine, GameEngine gameEngine) {
        this.mapEngine = mapEngine;
        this.gameEngine = gameEngine;
        //this.pangKeyListener = new PangKeyListener(keysPressed);
        //for example
        
    }

    public void applyKeyEvents() {
        if(keysPressed[PAUSE]){
            if (!gameEngine.isPaused()) {
                gameEngine.pause();
            }
            else {
                gameEngine.resume();
            }

        }

        else if(keysPressed[LEFT]){
        }

        else if(keysPressed[RIGHT]){
        }

        else if(keysPressed[SHOOT]){
        }

    }

    public void detectInput(KeyEvent e) {
        if(e.getKeyCode() == KeyEvent.VK_A){
            keysPressed[InputManager.LEFT] = true;
        }

        else if(e.getKeyCode() == KeyEvent.VK_D){
            keysPressed[InputManager.RIGHT] = true;
        }

        else if(e.getKeyCode() == KeyEvent.VK_P){
            keysPressed[InputManager.PAUSE] = true;
        }

        else if(e.getKeyCode() == KeyEvent.VK_SPACE){
            keysPressed[InputManager.SHOOT] = true;
        }
    }
}
